package oldVersion.server;

/**
 *@author Adam
 */

import javax.jmdns.JmDNS;
import javax.jmdns.ServiceInfo;

public class BonjourService{

	public static final String SERVICE_TYPE = "uss.local.";
	public static final String SERVICE_NAME = "local_service";
	public static final int SERVICE_PORT = 1270;
	JmDNS jmdns;
	ServiceInfo info;
	public static SocketConnect SSS;

	public BonjourService(){
		SSS = new SocketConnect(SERVICE_PORT);
	}

	public void registerService() {
		try{
			jmdns = JmDNS.create();
			info = ServiceInfo.create(SERVICE_TYPE, SERVICE_NAME, SERVICE_PORT, 0, 0,"a_property=some_value");
			jmdns.registerService(info);
			System.out.println("Registered Service as " + info);

		}
		catch(Exception e){
			System.out.println("problem registering BonjourListenService");
		}
		SSS.listen();
	}


	public void unregisterService() {
		jmdns.unregisterService(info);
		jmdns.close();	
	}

}
